/**
 * 
 */
package com.james.wee.shuangseqiu.tools;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.james.wee.shuangseqiu.bo.IDBBo;
import com.james.wee.shuangseqiu.bo.OpenNumber;
import com.james.wee.shuangseqiu.db.DB;

/**
 * @author JamesWee
 * 
 */
public class ToolsUtil {

	public static String getStr(String i) {
		int is = Integer.parseInt(i);
		String tmp = null;
		switch (is) {
		case 1:
			tmp = "N_1";
			break;
		case 2:
			tmp = "N_2";
			break;
		case 3:
			tmp = "N_3";
			break;
		case 4:
			tmp = "N_4";
			break;
		case 5:
			tmp = "N_5";
			break;
		case 6:
			tmp = "N_6";
			break;
		case 7:
			tmp = "N_7";
			break;
		case 8:
			tmp = "N_8";
			break;
		case 9:
			tmp = "N_9";
			break;
		case 10:
			tmp = "N_10";
			break;
		case 11:
			tmp = "N_11";
			break;
		case 12:
			tmp = "N_12";
			break;
		case 13:
			tmp = "N_13";
			break;
		case 14:
			tmp = "N_14";
			break;
		case 15:
			tmp = "N_15";
			break;
		case 16:
			tmp = "N_16";
			break;
		case 17:
			tmp = "N_17";
			break;
		case 18:
			tmp = "N_18";
			break;
		case 19:
			tmp = "N_19";
			break;
		case 20:
			tmp = "N_20";
			break;
		case 21:
			tmp = "N_21";
			break;
		case 22:
			tmp = "N_22";
			break;
		case 23:
			tmp = "N_23";
			break;
		case 24:
			tmp = "N_24";
			break;
		case 25:
			tmp = "N_25";
			break;
		case 26:
			tmp = "N_26";
			break;
		case 27:
			tmp = "N_27";
			break;
		case 28:
			tmp = "N_28";
			break;
		case 29:
			tmp = "N_29";
			break;
		case 30:
			tmp = "N_30";
			break;
		case 31:
			tmp = "N_31";
			break;
		case 32:
			tmp = "N_32";
			break;
		case 33:
			tmp = "N_33";
			break;

		default:
			break;
		}
		return tmp;
	}

	public static int getACValue(String rednum) {
		int R = 5;
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		String[] strnum = rednum.split(",");
		int[] nums = new int[strnum.length];
		for (int i = 0; i < strnum.length; i++) {
			nums[i] = Integer.parseInt(strnum[i]);
		}
		for (int i = 5; i > 0; i--) {
			for (int j = 5; j > (5 - i); j--) {
				map.put(nums[j] - nums[5 - i], 0);
			}
		}

		return (map.keySet().size() - R);
	}

	public static int jisuantf(OpenNumber uon, String shahao) {
		if (null == uon.sixRedNum())
			return 0;
		String[] ou = uon.sixRedNum().replaceAll(" ", "").split(",");
		int index = 0;
		for (String s : ou) {
			if (shahao.indexOf(s.trim()) != -1)
				index++;
		}
		return index;
	}

	public static void main(String[] args) {
String red = "09,12,23,26,29,30";
System.out.println(ToolsUtil.getACValue(red));
//		try {
//			List<IDBBo> list = DB.getInstance().queryBoList(
//					"SELECT * FROM OpenNumber    ORDER BY ID DESC ",
//					OpenNumber.class);
//			OpenNumber openobj = null;
//			Map<Integer,Integer> map  = new HashMap<Integer, Integer>();
//			for (IDBBo bo : list) {
//				openobj = (OpenNumber) bo;
//				int i =ToolsUtil.getACValue(openobj.sixRedNum());
//				map.put(i, i);
//				System.out.println(openobj.getOpennum()+"==>"+i);
//				
//			}
//			System.out.println(map);
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}

		//
		// String printStr = "##############################################\n"+
		// "#  t01  t02  t03  t04  t05  t06  t07  t08  t09  t10  t11  #\n"+
		// "#  01  02  03  04  05  06  07  08  09  10  11  #\n"+
		// "#  01k  02k  03k  04k  05k  06k  07k  08k  09k  10k  11k  #\n"+
		//
		// "#  t12  t13  t14  t15  t16  t17  t18  t19  t20  t21  t22  #\n"+
		// "#  12  13  14  15  16  17  18  19  20  21  22  #\n"+
		// "#  12k  13k  14k  15k  16k  17k  18k  19k  20k  21k  22k  #\n"+
		//
		// "#  t23  t24  t25  t26  t27  t28  t29  t30  t31  t32  t33  #\n"+
		// "#  23  24  25  26  27  28  29  30  31  32  33  #\n"+
		// "#  23k  24k  25k  26k  27k  28k  29k  30k  31k  32k  33k  #\n"+
		// "----------------------------------------------\n"+
		// "出现5次的占有开奖号：p5\n"+
		// "出现4次的占有开奖号：p4\n"+
		// "出现3次的占有开奖号：p3\n"+
		// "出现2次的占有开奖号：p2\n"+
		// "出现1次的占有开奖号：p1\n"+
		// "出现0次的占有开奖号：p2\n"+
		// "##############################################\n";
		// System.out.println(printStr);
	}
}
